package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import biz.UserplusBiz;
import entity.Userplus;

public class InsertUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public InsertUserServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String name = request.getParameter("name");
		String age = request.getParameter("age");
		String sex = request.getParameter("sex");
		Userplus userplus = new Userplus();
		userplus.setName(name);
		userplus.setAge(Integer.parseInt(age));
		userplus.setSex(Integer.parseInt(sex));
//		System.out.print(userplus.getName());
		UserplusBiz biz = new UserplusBiz();
//		System.out.println(name);
		biz.insertUserplus(userplus);
		request.getRequestDispatcher("SelectAllServlet?curpage=1").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
